﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="admin_worksadd.aspx.cs" Inherits="Web.admin_worksadd" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cssContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="jsContent" runat="server">

    <script type="text/javascript" language="javascript">
        $(function() {
            initSideNav("nav-work", "admin_worksadd.aspx");
        });
    </script>
    
    <script type="text/javascript" language="javascript">
        function divupload() {
            divuploader = new qq.FileUploaderBasic({
                button: document.getElementById('btnajaxuploadlist'),
                action: 'admin_uploadimage.aspx?action=upload',
                allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
                sizeLimit: 1024000,
                multiple: false,
                debug: true,
                onSubmit: function(id, fileName) {

                },
                onComplete: function(id, fileName, responseJSON) {
                    AddImage(id, fileName, responseJSON.filename);
                    //checkRadio(); //防止没有封面
                }
            });
        }
        function checkRadio() {
            if ($("input[name='headshow']:checked").val() == undefined) {
                $("input[name='headshow']").first().attr('checked', 'checked');
            }
        }

        function beforeSubmitWorks() {
            $("#ctl00_mainContent_btnSubmit").click(function() {
                if ($("input[name='headshow']:checked").val() == undefined) {
                    alert("请先设置选择图片封面！");
                    return false;
                }
            });
        }
        //每次都要加载的页面
        function worksadd() {
            divupload();
            //beforeSubmitWorks();
        }
        $(function() {
            worksadd();
        });
        function AddImage(id, fileName, fileUrl) {
            var img = "<img src='" + fileUrl + "' width='100px' />";
            var hidden = "<input type='hidden' name='picurl[]' value='" + fileUrl + "'/>";
            var op2 = "<a href='javascript:DeleteImage(" + id + ",0);'>删除</a>";
            var op = "<button onclick='DeleteImage(" + id + ",0);' class='uploadbtnclass'>删除</button>";
            //var headshow = "<input type='radio' name='headshow' value='" + fileUrl + "'/>";
            var level = "<input type='text' name='piclevel[]' value='" + (100 - id) + "' />";
            var name = "<input type='text' name='picname[]' value='" + fileName + "' />";
            var atr = "<tr class='file-row' id='file-0" + id + "'>";
            atr += "<td>" + img + hidden + "</td>";
            //atr += "<td>" + headshow + "</td>";
            atr += "<td>" + level + "</td>";
            atr += "<td>" + name + "</td>";
            atr += "<td>" + op + "</td>";
            $("#file-list").append(atr);
        }
        function DeleteImage(id, type) {
            if (type == 0) {
                $("#file-0" + id).remove();
            } else if (type == 1) {
                $("#file-delete").append("<input type='hidden' name='delete[]' value='" + id + "'>");
                $("#file-" + id).remove();
            }
            return false;
        }
    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="mainContent" runat="server">
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>
                案例管理</h3>
            <ul class="content-box-tabs">
                <li><a href="admin_works.aspx">列表</a></li>
                <li><a href="admin_worksadd.aspx" class="default-tab">添加</a></li>
            </ul>
            <div class="clear">
            </div>
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
                <!-- This is the target div. id must match the href of this div's tab -->
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
                    <ContentTemplate>
                        <div class="notification error png_bg" id="noticefail" runat="server">
                            <a href="#" class="close">
                                <img src="resources/images/icons/cross_grey_small.png" title="Close this notification"
                                    alt="close" /></a>
                            <div>
                                添加失败！请检查各个字段是否正确！如果多次失败，请联系技术！谢谢！
                            </div>
                        </div>
                        <div id="noticesuccess" runat="server">
                            <div class="notification success png_bg">
                                <a href="#" class="close">
                                    <img src="resources/images/icons/cross_grey_small.png" title="Close this notification"
                                        alt="close" /></a>
                                <div>
                                    添加成功！<a href="admin_works.aspx">返回列表</a>&nbsp;&nbsp;<a href="admin_worksadd.aspx">继续添加</a>
                                </div>
                            </div>
                        </div>
                        <fieldset>
                            <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                            <p>
                                <label>
                                    案例标题</label>
                                <asp:TextBox ID="txbTitle" runat="server" CssClass="text-input medium-input"></asp:TextBox>
                                </span>
                            </p>
                            <p>
                                <label>
                                    案例类型</label>
                                <asp:DropDownList ID="ddlCategory" runat="server">
                                </asp:DropDownList>
                            </p>
                            <div class="clear">
                            </div>
                            <p class="column-left">
                                <label>
                                    客户名称</label>
                                <asp:TextBox ID="txbCustomerName" runat="server" CssClass="text-input medium-input"></asp:TextBox>
                            </p>
                            <p class="column-right">
                                <label>
                                    合作时间:</label>
                                <asp:TextBox ID="txbTeamWorkTime" runat="server" CssClass="text-input medium-input"></asp:TextBox>
                            </p>
                            <div class="clear"></div>

                            <p style="min-height: 170px;">
                                <label>
                                    缩略图</label>
                                <span style="height: 140px;"><a class="shortcut-button" href="#uploadimage" id="openerupload"
                                    style="float: left;"><span>
                                        <img src="resources/images/icons/image_add_48.png" alt="icon" /><br />
                                        上传图片 </span></a><span style="margin: 20px; height: 140px;"></span>
                                    <asp:Image ID="imgPicUrl" runat="server" Width="130" Height="90" /><asp:HiddenField
                                        ID="hfPicUrl" runat="server" Visible="true" />
                                </span>
                            </p>
                            <div class="clear">
                            </div>
                            <p>
                                <div class="" id="uploadimage2">
                                    请选择缩略图进行上传，大小为450x250，或者保持此比例！<br />
                                    <br />
                                    <div id="divajaxupload">
                                    </div>
                                    
                                        <div id="btnajaxuploadlist" class="uploadbtnclass" >上传</div>
                                    <%--<button id="btnDeleteOldImagelist" onclick="deletePreImage();" class="deletebtnclass">
                                        删除</button>--%>
                                        <div class="clear"></div>
                                    <div id="file-upload-list">
                                        <table border="0">
                                            <thead>
                                                <tr>
                                                    <td>
                                                        图片预览
                                                    </td>
                                                    <td>
                                                        图片排序(越大越靠前，可忽略)
                                                    </td>
                                                    <td>
                                                        图片提示(鼠标移上去的提示)
                                                    </td>
                                                    <td>
                                                        操作
                                                    </td>
                                                </tr>
                                            </thead>
                                            <tbody id="file-list">
                                                <asp:Repeater ID="WorksPicRpt" runat="server">
                                                    <ItemTemplate>
                                                        <tr>
                                                            <td>
                                                                <img src='<%#Eval("PicURL") %>' width="100px" /><input type="hidden" name="picurl[]" value="<%#Eval("PicURL") %>">
                                                            </td>
                                                            <%--<td>
                                                                <input type='radio' name='headshow' value='<%#Eval("PicID") %>' />
                                                            </td>--%>
                                                            <td>
                                                                <input type="text" name="piclevel[]" value="<%#Eval("PicLevel") %>">
                                                            </td>
                                                            <td>
                                                                <input type="text" name="picname[]" value="<%#Eval("PicName") %>">
                                                            </td>
                                                            <td>
                                                                <%--<a href="javascript:DeleteImage(<%#Eval("PicID") %>,1);">删除</a>--%>
                                                                <button onclick="DeleteImage(<%#Eval("PicID") %>,1);" value="删除" class='uploadbtnclass'>
                                                                    删除</button>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                            </tbody>
                                        </table>
                                        <div id="file-delete">
                                        </div>
                                    </div>
                                </div>
                            </p>
                            <p>
                                 <label>
                                    内容简介</label>
                                <asp:TextBox ID="txbWorksBrief" runat="server" CssClass="text-input large-input"></asp:TextBox>
                            </p>
                            <p>
                                <label>
                                    案例内容</label>
                                <CKEditor:CKEditorControl ID="txbContent" runat="server" Columns="79" CssClass="text-input textarea"
                                    Rows="15" TextMode="MultiLine"></CKEditor:CKEditorControl>
                            </p>
                            <p>
                                <asp:Button ID="btnSubmit" runat="server" CssClass="button" OnClick="btnSubmit_OnClick"
                                    Text="提交" />
                                <input class="button" type="Reset" value="取消" />
                            </p>
                            <p>
                            </p>
                            </span>
                        </fieldset>
                        <div class="clear">
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div class="" id="uploadimage" style="display: none;">
                    请选择缩略图进行上传，大小为130x90，或者保持此比例！<br />
                    <div id="file-uploader">
                        <noscript>
                            <p>
                                Please enable JavaScript to use file uploader.</p>
                            <!-- or put a simple form for upload here -->
                        </noscript>
                    </div>
                    <div id="btnajaxupload" class="uploadbtnclass">
                    上传
                    </div>
                    <%--<button id="btnajaxupload" value="upload">
                        upload</button>--%>
                    <button id="btnDeleteOldImage" onclick="deletePreImage();"  class="deletebtnclass">
                        删除</button>
                    <div id="file-upload-show" style="display: none;">
                        <img src="" id="image-upload-show" title="预览" />
                    </div>
                </div>
                <!-- End .clear -->
            </div>
            <!-- End #tab1 -->
        </div>
        <!-- End .content-box-content -->
    </div>
</asp:Content>
